package com.sgb.kjwl.view.widget.map;

import android.content.Context;
import androidx.databinding.DataBindingUtil;
import androidx.annotation.Nullable;
import android.util.AttributeSet;
import android.view.LayoutInflater;
import android.widget.LinearLayout;

import com.sgb.kjwl.R;
import com.sgb.kjwl.databinding.MapPackersWindowBinding;
import com.sgb.kjwl.model.entity.packers.PackersMapEntity;

/**
 * Description:
 * Author zhengkewen
 * Time 2020/7/15
 */
public class PackersMapWindow extends LinearLayout {

    protected Context mContext;
    protected MapPackersWindowBinding viewBinding;
    private PackersMapEntity packersMapEntity;

    public PackersMapWindow(Context context) {
        this(context, null);
    }

    public PackersMapWindow(Context context, @Nullable AttributeSet attrs) {
        this(context, attrs, 0);
    }

    public PackersMapWindow(Context context, @Nullable AttributeSet attrs, int defStyleAttr) {
        this(context, attrs, defStyleAttr, 0);
    }

    public PackersMapWindow(Context context, AttributeSet attrs, int defStyleAttr, int defStyleRes) {
        super(context, attrs, defStyleAttr);
        this.mContext = context;
        initView();
    }

    private void initView() {
        viewBinding = DataBindingUtil.inflate(LayoutInflater.from(mContext), R.layout.map_packers_window, this, true);
    }

    public void setMarker(int res) {
        viewBinding.markLayout.setBackgroundResource(res);
    }

    public void setWorkData(PackersMapEntity packersMapEntity) {
        this.packersMapEntity = packersMapEntity;
        viewBinding.nameView.setText(packersMapEntity.getName());
        viewBinding.contentView.setText(packersMapEntity.getNum() + "个项目");
    }

    public void setTeamData(PackersMapEntity packersMapEntity) {
        this.packersMapEntity = packersMapEntity;
        viewBinding.nameView.setText(packersMapEntity.getName());
        viewBinding.contentView.setText(packersMapEntity.getNum() + "个工队");
    }

    public PackersMapEntity getData() {
        return packersMapEntity;
    }
}
